<template>
    <el-dialog :visible.sync="addVisible" width="80%" :show-close='false' :closeOnClickModal='false' :class="{'addSampleForm':true,'standardseries':true,'dataEntrySeries':standarModel != 'mygrouptest'}"  ref="standardseries">
        <span slot="title" class="dialog-title">

            标准系列

            <!--<el-button type="primary" @click="historyLine" size="mini" class="popupClose" style="margin-right:70px;" v-if = "standarModel == 'mygrouptest'">历史曲线</el-button>-->

            <el-button @click="closeStandardSeries()" size="mini" class="popupClose">关闭</el-button>

        </span>
        <div class="standardTitle">
            <el-input placeholder="请输入内容" size="mini" v-model="name" :disabled="standarModel != 'mygrouptest'"></el-input>标准系列配制记录表
        </div>
        <div class="form">
            <el-form label-width="80px" :inline="false" class="demo-form-inline" :model="standardSeriesForm" :rules="standardSeriesFormRules" ref="standardSeriesForm">

                <el-form-item label="编号" prop="code">
                    <el-col :span="22">
                        <el-input placeholder="例：氨氮-190426-01" size="mini" v-model="standardSeriesForm.code" :disabled="standarModel != 'mygrouptest'"></el-input>
                    </el-col>
                </el-form-item>
                <el-form-item label="温度(℃)" prop="temperature">
                    <el-col :span="22">
                        <el-input size="mini" v-model="standardSeriesForm.temperature" :min="0" class="controlsPosition deal" style="width:100%" :disabled="standarModel != 'mygrouptest'"></el-input>

                    </el-col>
                </el-form-item>
                <el-form-item label="湿度(%)" prop="humcodeity">
                    <el-col :span="22">
                        <el-input  size="mini" v-model="standardSeriesForm.humcodeity" :min="0" class="controlsPosition deal" style="width:100%" :disabled="standarModel != 'mygrouptest'"></el-input>
                    </el-col>
                </el-form-item>
                <el-tooltip class="item" effect="dark" content="仅使用紫外/可见分光光度计测定新增曲线时需勾选，其它上传附件即可" placement="top">
                    <el-form-item label="是否应用" prop="doUse" style = "width:10%;">
                        <el-col :span="22">

                            <el-checkbox v-model="standardSeriesForm.doUse" @change="itemSize" :disabled="standarModel != 'mygrouptest'"></el-checkbox>
                        </el-col>
                    </el-form-item>
                </el-tooltip>
                <el-form-item label="配制日期" prop="configDate">
                    <el-col :span="22">
                        <el-date-picker size="mini" type="date" v-model="standardSeriesForm.configDate" style="width:100%" format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择日期" :disabled="standarModel != 'mygrouptest'">
                        </el-date-picker>
                    </el-col>
                </el-form-item>
                <el-form-item label="配制人" prop="configMan">
                    <el-col :span="22">
                        <el-select v-model="standardSeriesForm.configMan" placeholder="请选择" size="mini" :disabled="standarModel != 'mygrouptest'">
                            <el-option v-for="item in userData" :key="item.account" :label="item.name" :value="item.account" :disabled="item.disabled">
                            </el-option>
                        </el-select>
                    </el-col>
                </el-form-item>
                <el-form-item label="校核人" prop="checker" v-if="false">
                    <el-col :span="22">
                        <el-select v-model="standardSeriesForm.checker" placeholder="请选择" size="mini" :disabled="standarModel != 'mygrouptest'">
                            <el-option v-for="item in userData" :key="item.account" :label="item.name" :value="item.account" :disabled="item.disabled">
                            </el-option>
                        </el-select>

                    </el-col>
                </el-form-item>
                <el-form-item label="扣除空白"  label-width="125px" prop="mustZone" style = "width:10%;">
                    <el-col :span="22">
                      <!-- {{standardSeriesForm.mustZone}} -->
                        <el-checkbox v-model="standardSeriesForm.mustZone" :disabled="standarModel != 'mygrouptest'"></el-checkbox>
                    </el-col>
                </el-form-item>
            </el-form>

        </div>
        <div class="elTab standardTable">
            <el-tabs style="width:100%;" v-model="activeName">
                <el-tab-pane label="标准溶液" name="first">
                    <el-button size="mini" type="primary" style="float:right" class="inlineBlock" @click="addStandardSolution" v-if="standarModel == 'mygrouptest'">添加标准溶液</el-button>
                    <el-radio-group v-model="matterType" class="checkbox inlineBlock" style="float:right;margin-right:55px;" :disabled="standarModel != 'mygrouptest'">
                        <el-radio :label="1">单标</el-radio>
                        <el-radio :label="2">混标</el-radio>
                    </el-radio-group>
                    <el-table :data="standardSolution" style="width: 100%" size="mini" class="solution">
                        <el-table-column property="name" label="标准溶液类型" fixed min-width="150">
                            <template slot-scope="scope">
                                <el-input type="text" size="mini" v-model="scope.row.name" placeholder="请输入内容" :disabled="standarModel != 'mygrouptest'"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column property="matter" label="标准物质名称及编号" min-width="150">
                            <template slot-scope="scope">
                                <el-input type="text" size="mini" v-model="scope.row.matter" placeholder="请输入内容" :disabled="standarModel != 'mygrouptest'"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column property="matterConcen" :render-header="renderHeader" min-width="150">
                            <template slot-scope="scope">
                                <el-input  size="mini" v-model="scope.row.matterConcen" :min="0" class="controlsPosition deal" :disabled="standarModel != 'mygrouptest'"></el-input>

                            </template>
                        </el-table-column>
                        <el-table-column property="matterAmount" min-width="150" :render-header="renderHeader">
                            <template slot-scope="scope">
                                <el-input size="mini" v-model="scope.row.matterAmount" :min="0" class="controlsPosition deal" :disabled="standarModel != 'mygrouptest'"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column property="volum" :render-header="renderHeader" min-width="150">
                            <template slot-scope="scope">
                                <el-input   size="mini" v-model="scope.row.volum" :min="0" class="controlsPosition deal" :disabled="standarModel != 'mygrouptest'"></el-input>

                            </template>
                        </el-table-column>
                        <el-table-column property="matrix" label="基体" min-width="100">
                            <template slot-scope="scope">
                                <el-input type="text" size="mini" v-model="scope.row.matrix" placeholder="请输入内容" :disabled="standarModel != 'mygrouptest'"></el-input>
                            </template>
                        </el-table-column>

                        <el-table-column property="configConcen" :render-header="renderHeader" min-width="150">
                            <template slot-scope="scope">
                                <el-input   size="mini" v-model="scope.row.configConcen" :min="0" class="controlsPosition deal" :disabled="standarModel != 'mygrouptest'"></el-input>

                            </template>
                        </el-table-column>

                        <el-table-column label="操作" min-width="100" v-if="standarModel == 'mygrouptest'">
                            <template slot-scope="scope">
                                <el-button type="text" size="small" @click="deleteStandardSolution(scope.$index)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="标准系列" name="second">
                    <el-button size="mini" type="primary" style="float:right" class="inlineBlock" @click="addStandardSeries" v-if="standarModel == 'mygrouptest'">添加标准系列</el-button>
                    <el-radio-group v-model="configWay" class="checkbox inlineBlock" style="float:right;margin-right:55px;" :disabled="standarModel != 'mygrouptest'">
                        <el-radio :label="1">人工配制</el-radio>
                        <el-radio :label="2">仪器配制</el-radio>
                    </el-radio-group>
                    <el-table :data="standardSeries" style="width: 100%" size="mini" border class="tableCon seriesTable">
                        <el-table-column label="序号" width="50">
                            <template slot-scope="scope">
                                {{scope.$index+1}}
                            </template>
                        </el-table-column>
                        <el-table-column property="seriesItem" label="项目" width="100">
                            <template slot-scope="scope">
                                <el-input type="text" size="mini" v-model="scope.row.seriesItem" placeholder="请输入内容" :disabled="standarModel != 'mygrouptest'"></el-input>
                            </template>
                        </el-table-column>
                        <el-table-column label="标准系列" class="seriesTd" min-width="300px">
                            <template slot-scope="scope">
                                <el-table :data="scope.row.custom.standardSeriesChild" style="width: 100%" size="mini" class="seriesChildTable">
                                    <el-table-column label="标准系列序号" width="110px" property="title" fixed>
                                    </el-table-column>
                                    <el-table-column property="unitValue" width="110px" fixed>
                                        <template slot-scope="scope">
                                            <el-select v-model="scope.row.unitValue" size="mini" filterable placeholder="单位" class="unitSeries" :disabled="standarModel != 'mygrouptest'">
                                                <el-option v-for="item in allUnit" :key="item.id" :label="item.ename" :value="item.id" :disabled="item.status == 0">
                                                </el-option>
                                            </el-select>
                                        </template>
                                    </el-table-column>
                                    <el-table-column v-for="col in scope.row.custom.colsData" :key="col.value" :label="col.label">
                                        <template slot-scope="scope">
                                            <el-input   size="mini" v-model="scope.row[col.value]" :min="0" class="controlsPosition borderNone deal" :disabled="standarModel != 'mygrouptest'"></el-input>

                                        </template>
                                    </el-table-column>

                                </el-table>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" width="90" v-if="standarModel == 'mygrouptest'">
                            <template slot-scope="scope">
                                <el-button type="text" size="small" @click="copyStandardSeries(scope.row)" :disabled="standardSeriesForm.doUse">复制</el-button>
                                <el-button type="text" size="small" @click="deleteStandardSeries(scope.$index)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="曲线图谱" name="third" v-if="standarModel != 'mygrouptest'">
                    <div style="width: 100%; height: 100%;margin:auto; overflow:auto;">
                        <el-table :data="standardTable.seriesRow" style="width: 100%;height:120px" size="mini">
                            <el-table-column label="标准系列序号" width="110px" property="title" fixed>
                            </el-table-column>

                            <el-table-column v-for="col in standardTable.seriesTitle" :key="col.value" :label="col.label">
                                <template slot-scope="scope">
                                    {{scope.row[col.value]}}
                                </template>
                            </el-table-column>
                        </el-table>
                        <!--getCoefficientObj-->
                        <div style="height:350px;">
                            <div style="width:18%;float:left;margin-top:10px;">
                                <p style="height:40px;line-height:40px;">a ：{{getCoefficientObj.slope}}</p>
                                <p style="height:40px;line-height:40px;">b ：{{getCoefficientObj.deviation}}</p>
                                <p style="height:40px;line-height:40px;">R : {{getCoefficientObj.coefficent}}</p>

                            </div>
                            <div id="seriesMap" style="width:82%;height:300px;margin:auto;float:right"></div>
                        </div>

                    </div>
                </el-tab-pane>
                <el-tab-pane label="附件" :disabled="standardSeriesForm.doUse" name="fourth">
                    <el-button type="primary" size="mini" style="float:right;margin-bottom:5px" @click="uploadClick">上传</el-button>
                    <form id="fileForm">
                        <input type="file" name="file" id="file" @change="upload" multiple>
                    </form>
                    <el-table style="width: 100%" size="mini" :data="attachmentBeanList" height="calc(100% - 33px)">
                        <el-table-column label="序号" min-width="50px">
                            <template slot-scope="scope">
                                {{scope.$index+1}}
                            </template>
                        </el-table-column>
                        <el-table-column property="fileName" label="附件名称" min-width="200px" :show-overflow-tooltip="true">
                        </el-table-column>
                        <el-table-column property="fileSize" label="附件大小" min-width="100px">
                            <template slot-scope="scope">
                                {{scope.row.fileSize == 0 ? 1 : scope.row.fileSize }} KB
                            </template>
                        </el-table-column>
                        <el-table-column property="createByName" label="上传人" min-width="80px">
                        </el-table-column>
                        <el-table-column property="createTime" label="上传时间" min-width="100px" :formatter="timeFormatter">
                        </el-table-column>
                        <el-table-column label="操作" min-width="100px">
                            <template slot-scope="scope">
                                <el-button type="text" size="mini" @click="deleteattachment(scope.row)">删除</el-button>
                                <!--downloadattachment-->
                                <el-button type="text" size="mini" @click="downloadattachment(scope.row)">下载</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
        </div>
        <span slot="footer" class="dialog-footer" v-if="standarModel == 'mygrouptest'">

            <el-button type="primary" size="mini" @click="subStandard">确定</el-button>

            <el-button type="primary" size="mini" @click="deleteCriterion">废弃</el-button>

            <el-button size="mini" @click="closeStandardSeries()">取 消</el-button>

        </span>
    </el-dialog>
</template>

<script>
import $ from 'jquery'
import {
    mapState
} from 'vuex'

export default {
    data() {
        return {
            isUse: false,
            name: '', //标准系列配置表头
            matterType: 1,
            configWay: 1,
            standardSolution: [], //标准溶液
            standardSeriesForm: {
                code: '',
                configDate:this.util.date(),
                temperature: '',
                humcodeity: '',
                doUse: false,
                checker: '',
                configMan: JSON.parse(sessionStorage.getItem('laboratoryAccountInfo')).loginid,
                mustZone:true,

            }, //标准系列表格
            standardSeriesFormRules: { //标准系列验证规则
                configDate: [{
                    required: true,
                    type: 'string',
                    message: '请选择配置时间',
                    trigger: "change",
                },],
                temperature: [{
                    required: true,
                    message: '请填写温度',
                    trigger: 'blur'
                },],
                humcodeity: [{
                    required: true,
                    message: '请填写湿度',
                    trigger: 'blur'
                }],
                configMan: [{
                    required: true,
                    message: '请选择配置人',
                    trigger: 'change'
                },],
                checker: [{
                    required: true,
                    message: '请选择校核人',
                    trigger: 'change'
                },],
            },
            unitTitle: {
                unitOne: '', //标准物质用量单位
                unitTwo: '', //标准物质浓度单位
                unitThree: '', //定容体积 单位
                unitFour: '', //配置浓度绑定单位
            },
            standardSeries: [], //标准系列
            attachmentBeanList: [], //附件
            criterionId: '', //更新时要传的id
            breakFlag: 1, //是否中断提交
            disabledUnit: true, //是否禁止填写单位
            testpanelForm: {},
            isDisabled: false, //是否可用
            activeName: 'first',
            standardTable: {}, //标准系列表
            getCoefficientObj: {
                coefficent: null, //相关系数
                deviation: null, //截距
                slope: null, //斜率
            },
            setIntervalTimes: null,
            isSuccess:true,

        }
    },
    watch: {
        addVisible(val) {
            if (val) {
                console.log(this.standarModel, this.newOrEdit)

                this.standardSeriesForm = this.standardSeriesDetail;
                console.log(this.standardSeriesForm.mustZone)

                if(this.standardSeriesForm.mustZone == undefined || this.standardSeriesForm.mustZone == ""
                || this.standardSeriesForm.mustZone == null){
                  if(this.standarModel == 'mygrouptest'){ //如果是检测安排，没有值则默认为true
                    // this.standardSeriesForm.mustZone = true;
                    this.$set(this.standardSeriesForm,'mustZone',true)
                  }else{ //数据录入没有值设置为false
                  this.$set(this.standardSeriesForm,'mustZone',false)
                    // this.standardSeriesForm.mustZone = false;
                  }
                }
                this.testpanelForm = this.testpanelDetail;
                if (this.standarModel == 'mygrouptest') {
                    this.name = this.testpanelForm.detectabilityName
                }
                if (this.newOrEdit == "edit") {
                    this.criterionId = this.standardSeriesForm.id //更新时保存的id
                    this.name = this.standardSeriesForm.name;
                    this.matterType = this.standardSeriesForm.matterType; //单标或者混标
                    this.configWay = this.standardSeriesForm.configWay; //人工配置或者仪器配置
                    // 标准溶液表头四个单位
                    this.unitTitle.unitOne = this.standardSeriesForm.unitOne;
                    this.unitTitle.unitTwo = this.standardSeriesForm.unitTwo
                    this.unitTitle.unitThree = this.standardSeriesForm.unitThree
                    this.unitTitle.unitFour = this.standardSeriesForm.unitFour
                }
                // 如果是新增并且有历史数据
                if(this.standardSeriesForm.solutionBeans !== null && this.standardSeriesForm.solutionBeans !== undefined && this.standardSeriesForm.solutionBeans !== ""){
                    this.standardSolution = this.standardSeriesForm.solutionBeans; //标准溶液数据
                }else{
                     this.standardSolution = [];
                }

                // 标准系列数据
                if(this.standardSeriesForm.itemBeans !== null && this.standardSeriesForm.itemBeans !== undefined && this.standardSeriesForm.itemBeans !== ''){
                    var temp = []
                    for (var i in this.standardSeriesForm.itemBeans) {

                        var obj = {};
                        obj.seriesItem = this.standardSeriesForm.itemBeans[i].itemName; //项目名称
                        obj.custom = {};
                        obj.custom.standardSeriesChild = [] //子表数组
                        obj.custom.colsData = []
                        for (var j in this.standardSeriesForm.itemBeans[i].seriesBeans) { //子表标头 std1 std2 ...
                            var colsDataObj = {};
                            colsDataObj.label = this.standardSeriesForm.itemBeans[i].seriesBeans[j].seriesSort

                            colsDataObj.value = this.standardSeriesForm.itemBeans[i].seriesBeans[j].seriesSort
                            obj.custom.colsData.push(colsDataObj)
                        }
                        var arr = [];
                        for (var k = 0; k < 4; k++) { //子表的四行数据
                            var childObj = {};
                            for (var j in this.standardSeriesForm.itemBeans[i].seriesBeans) { //遍历列（一共有几个std）
                                if (k == 0) {
                                    childObj.title = '标准使用液浓度';
                                    childObj.unitValue = this.standardSeriesForm.itemBeans[i].unitOne;
                                    childObj[this.standardSeriesForm.itemBeans[i].seriesBeans[j].seriesSort] = this.standardSeriesForm.itemBeans[i].seriesBeans[j].criterionConcen;
                                } else if (k == 1) {
                                    childObj.title = '标准物质用量';
                                    childObj.unitValue = this.standardSeriesForm.itemBeans[i].unitTwo;
                                    childObj[this.standardSeriesForm.itemBeans[i].seriesBeans[j].seriesSort] = this.standardSeriesForm.itemBeans[i].seriesBeans[j].matterAmount;
                                } else if (k == 2) {
                                    childObj.title = '定容量';
                                    childObj.unitValue = this.standardSeriesForm.itemBeans[i].unitThree;
                                    childObj[this.standardSeriesForm.itemBeans[i].seriesBeans[j].seriesSort] = this.standardSeriesForm.itemBeans[i].seriesBeans[j].volum;
                                } else if (k == 3) {
                                    childObj.title = '标准系列浓度';
                                    childObj.unitValue = this.standardSeriesForm.itemBeans[i].unitFour;
                                    childObj[this.standardSeriesForm.itemBeans[i].seriesBeans[j].seriesSort] = this.standardSeriesForm.itemBeans[i].seriesBeans[j].seriesConcen;
                                }
                            }

                            obj.custom.standardSeriesChild.push(childObj)

                        }
                        temp.push(obj)
                    }
                    this.standardSeries = temp;
                }


                if (this.standarModel != 'mygrouptest') { //如果弹框是从数据录入点击弹出，输入框不可用
                    this.isDisabled = true;
                }
                console.log(this.signalObj)
                if (this.standarModel == 'mygrouptest') { //如果是检测安排的标准系列，需要每隔10s提交一次数据

                    var that = this;
                    this.setIntervalTimes = setInterval(function() {
                        if(that.isSuccess){
                            that.clickOrTimeSub('time')
                        }
                    }, 10000 * 6)
                }
            }
        },
        activeName(val) {
            if (val == "third") {
                console.log(this.standardSeriesForm.itemBeans[0].seriesBeans, this.signalObj)
                this.standardTable.series = this.standardSeriesForm.itemBeans[0].seriesBeans
                this.standardTable.seriesRow = []; //表两列数据
                this.standardTable.seriesTitle = []; //表头数据
                if (this.standardTable.series != undefined) {
                    for (var i in this.standardTable.series) { //组装表头
                        var obj = {};
                        obj.value = this.standardTable.series[i].seriesSort;
                        obj.label = this.standardTable.series[i].seriesSort;
                        this.standardTable.seriesTitle.push(obj);
                    }
                }
                //渲染曲线图谱的数据
                var seriesFlag = false;
                for (var k = 0; k < 2; k++) { //渲染标准系列表的内容
                    var childObj = {};
                    if (this.standardTable.series != undefined) {
                        for (var i in this.standardTable.series) {
                            if (k == 0) {
                                childObj.title = '标准系列浓度';
                                childObj[this.standardTable.series[i].seriesSort] = this.standardTable.series[i].seriesConcen;

                            } else if (k == 1) {
                                childObj.title = '标准系列信号值';
                                console.log(this.stringNotEmpty(this.signalObj[this.standardTable.series[i].seriesSort]))
                                childObj[this.standardTable.series[i].seriesSort] = this.stringNotEmpty(this.signalObj[this.standardTable.series[i].seriesSort]) ? this.signalObj[this.standardTable.series[i].seriesSort] : null;
                                if (this.signalObj[this.standardTable.series[i].seriesSort] == undefined) {
                                    seriesFlag = true;
                                }
                            }
                        }
                    }
                    this.standardTable.seriesRow.push(childObj)
                }
                if (seriesFlag) {
                    this.$notify({
                        title: "警告",
                        message: "缺少信号值",
                        type: "wraning"
                    });
                    //return;
                }
                //渲染曲线
                console.log(this.standardTable.seriesRow)
                var arr = []; //一组点位[[x,y],[x1,y1],[x2,y2],[x3,y3]、、、]
                for (var i in this.standardTable.seriesRow[0]) {
                    if (i != 'title' && this.standardTable.seriesRow[1][i] != null && this.standardTable.seriesRow[0][i] != null) {
                        var childArr = []; //一个点位的坐标[x,y]
                        childArr[0] = this.standardTable.seriesRow[0][i]; //x的坐标
                        childArr[1] = this.standardTable.seriesRow[1][i]; //y的坐标
                        arr.push(childArr)
                    }

                }
                var x = [],
                    y = [];
                for (var j in arr) {
                    x.push(Number(arr[j][0]));
                    y.push(Number(arr[j][1]));
                }
                this.getCoefficient(x, y, arr)

            } else if (val == 'fourth') {
                this.getFilePath()
            }
        }
    },
    props: ['addVisible', 'newOrEdit', 'standardSeriesDetail', 'userData', 'allUnit', 'testpanelDetail', 'standarModel', 'signalObj'],
    components: {

    },
    mounted() {

    },
    beforeDestroy() {
        this.isSuccess = true;
        clearInterval(this.setIntervalTimes)
    },
    computed: {
        ...mapState(['tableHeightA']),

    },
    methods: {

        timeFormatter(row, column, cellValue, index) {
            return this.util.formatterDate({
                cellValue: cellValue
            })
        },
        // 渲染标准溶液表头部的单位input框
        renderHeader(h, {
            column,
            $index
        }) {

            var that = this;
            var label = '';
            var mes = "";
            var unitValue1 = '';
            var unitValue2 = '';
            var unitValue3 = '';
            // var unitUse = true;
            for (var i in this.allUnit) { //初始值默认
                if (this.allUnit[i].ename == "mg/L") {
                    unitValue2 = this.allUnit[i].id;
                }
                if (this.allUnit[i].ename == "mL") {
                    unitValue3 = this.allUnit[i].id;
                }
            }

            if ($index == '2') { //根据当前列是第几列显示表头和为输入框绑定值
                label = "标准物质浓度";
                mes = 'unitOne';
            } else if ($index == '3') {
                label = "标准物质用量"
                mes = 'unitTwo';
            } else if ($index == '4') {
                label = "定容体积"
                mes = 'unitThree';
            } else if ($index == '6') {
                label = "配置浓度"
                mes = 'unitFour';

            }
            // 如果是新加的标准系列的默认显示单位
            if (this.unitTitle.unitOne == '' || this.unitTitle.unitOne == null) {
                this.unitTitle.unitOne = unitValue2;
            }
            if (this.unitTitle.unitTwo == '' || this.unitTitle.unitTwo == null) {
                this.unitTitle.unitTwo = unitValue3;
            }
            if (this.unitTitle.unitThree == '' || this.unitTitle.unitThree == null) {
                this.unitTitle.unitThree = unitValue3;
            }
            if (this.unitTitle.unitFour == '' || this.unitTitle.unitFour == null) {
                this.unitTitle.unitFour = unitValue2;
            }
            return h('div', {
                style: {
                    height: '63px',
                    lineHeight: "27px",
                },
            }, [
                    h("span", { //div里面有一个文字提示：下拉框所属内容
                        style: {},
                    }, label),
                    h("br", {

                    }),
                    h('el-select', { //el-input

                        on: { //这是方法
                            input: (value) => {

                                that.$set(that.unitTitle, mes, value);

                            },
                        },
                        style: {
                            width: '110px',
                        },
                        class: 'el-input--mini unitSolution',

                        props: {
                            value: that.unitTitle[mes],
                            placeholder: '单位',
                            filterable: true,
                            disabled: this.isDisabled
                        },

                    }, [this.allUnit.map(item => {
                        return h("el-option", {
                            props: {
                                value: item.id,
                                label: item.ename
                            }
                        })
                    })])
                ])
        },
        // 添加标准溶液
        addStandardSolution() {
            this.standardSolution.push({
                name: '',
                matter: '',
                matterConcen: '',
                matterAmount: '',
                volum: '',
                matrix: '',
                configConcen: '',

            })
        },
        // 添加标准系列
        addStandardSeries() {
            // 如果勾选是否应用，不能添加长度大于1标准系列项目
            if (this.standardSeriesForm.doUse && this.standardSeries.length > 0) {
                this.$message({
                    type: 'info',
                    message: '已勾选"是否应用",只能添加一个项目'
                });
                return;
            }
            this.$prompt('请输入标准点个数', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                // inputPattern: /^[5-9]|10\d*$/,
                inputPattern: /^([5-9]?|10)$/,
                inputErrorMessage: '请输入大于5小于10的整数',
                closeOnClickModal:false,
            }).then(({
                value
            }) => {
                this.$message({
                    type: 'success',
                    message: '你的要加入的列数是: ' + value
                });
                var colsData = [];
                var obj = {};
                for (var i = 1; i <= value; i++) {
                    obj = {
                        value: "std" + i,
                        label: "std" + i
                    }
                    colsData.push(obj)
                }
                var unitValue1 = '';
                var unitValue2 = '';
                var unitValue3 = '';
                // var unitUse = true;
                for (var i in this.allUnit) { //初始值默认
                    if (this.allUnit[i].ename == "mg/L") {
                        unitValue2 = this.allUnit[i].id;
                    }
                    if (this.allUnit[i].ename == "mL") {
                        unitValue3 = this.allUnit[i].id;
                    }
                }
                console.log(colsData)
                // 添加时如果勾选是否应用，默认单位为mg/l，并且不可用
                // if (this.standardSeries.length == 0 && this.standardSeriesForm.doUse) {
                // 	unitValue1 = unitValue2
                // }
                this.standardSeries.push({
                    seriesItem: '',
                    custom: {
                        standardSeriesChild: [{
                            title: '标准使用液浓度',
                            unitValue: unitValue2,
                        }, {
                            title: '标准物质用量',
                            unitValue: unitValue3,
                        }, {
                            title: '定容量',
                            unitValue: unitValue3,
                        }, {
                            title: '标准系列浓度',
                            unitValue: unitValue2,
                        }],
                        colsData
                    },

                })

            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '取消输入'
                });
            });

        },
        // 点击是否应用时调用的函数
        itemSize(val) {
            // 如果勾选并且标准系列长度大于1，不能勾选
            if (val && this.standardSeries.length > 1) {
                this.$message({
                    type: 'info',
                    message: '标准系列项目大于1条,请删除后再勾选'
                });
                this.standardSeriesForm.doUse = false;
            }

            // this.defaultUnit(val); //如果勾选是否应用 默认设置标准系列浓度单位为mg/l 其他列清空(这里有个大bug,勾选了是否应用之后,最后一行不能输入)
        },
        // 如果勾选是否应用 默认设置标准系列浓度单位为mg/l 其他列清空
        defaultUnit(val) {

            if (val && this.standardSeries.length == 1) {
                var unitValue = '';
                for (var i in this.allUnit) { //初始值默认
                    if (this.allUnit[i].ename == "mg/L") {
                        unitValue = this.allUnit[i].id;
                    }

                }
                // 清空第四行数据，循环std数据
                for (var j in this.standardSeries[0].custom.colsData) {
                    console.log(this.standardSeries[0].custom.standardSeriesChild[3])
                    var std = this.standardSeries[0].custom.colsData[j].value
                    this.standardSeries[0].custom.standardSeriesChild[3][std] = null;
                }
                this.standardSeries[0].custom.standardSeriesChild[3].unitValue = unitValue;
                this.standardSeries[0].custom.standardSeriesChild[3].title = '标准系列浓度';
                this.standardSeries[0].custom.standardSeriesChild[3].unit = '单位 : '
                // this.standardSeries[0].custom.standardSeriesChild[3].disabledUnit = false;
            }
            // 不准修改标准系列浓度单位

        },
        // 废弃标准系列
        deleteCriterion() {
            console.log(this.testpanelForm.sampleBeans)
            var data = {
                id: this.standardSeriesDetail.id
            };
            this.$http({
                method: 'post',
                apiUrl: '/detection/deleteCriterion.htm',
                params: data,
                isJson: false,
            }).then(res => {
                if (res.code === 0) {
                    // 标准系列作废后 ，已选样品中是标准系列得删除
                    var arr = JSON.parse(JSON.stringify(this.testpanelForm.sampleBeans))
                    for (var i = arr.length - 1; i >= 0; i--) {
                        if (arr[i].doStandard) {
                            this.testpanelForm.sampleBeans.splice(i, 1)
                        }
                    }
                    this.testpanelForm.hasCriterion = false; //查看标准系列按钮变为添加
                    this.closeStandardSeriesShow();
                }

            })
        },
        // 删除标准溶液
        deleteStandardSolution(index) {
            this.standardSolution.splice(index, 1)
        },
        // 删除标准系列
        deleteStandardSeries(index) {
            this.standardSeries.splice(index, 1)
        },
        // 验证标准系列不为空  如果是点击提交的话要验证，定时提交的话不用
        isNotNull(str, msg, clickOrTime) {
            if (clickOrTime == 'click') {
                if (str == "" || str == undefined) {
                    this.$message({
                        type: 'info',
                        message: msg + "不能为空！"
                    })
                    this.breakFlag = 0;
                } else {
                    this.breakFlag = this.breakFlag * 1;
                    return str;
                }
            } else {
                this.breakFlag = this.breakFlag * 1;
                return str;
            }

        },
        stringNotEmpty(str) {
            if (str !== undefined && str !== null && str !== '') {
                return true;
            } else {
                return false;
            }
        },
        // 定时提交数据 还是点击提交数据
        clickOrTimeSub(clickOrTime) {
          console.log(this.standardSeriesForm)
            this.breakFlag = 1;
            var subStandardSeries = {};
            //定义要提交的对象
            subStandardSeries.batch = this.testpanelForm.id; //批次
            subStandardSeries.detectability = this.testpanelForm.detectability; //能力参数
             subStandardSeries.equipment = this.testpanelForm.equipment; //仪器
            subStandardSeries.name = this.isNotNull(this.name, '表名', clickOrTime);
            subStandardSeries.code = this.standardSeriesForm.code; //编码
            subStandardSeries.configDate = this.standardSeriesForm.configDate; //配置日期
            subStandardSeries.temperature = this.standardSeriesForm.temperature; //温度
            subStandardSeries.humcodeity = this.standardSeriesForm.humcodeity; //湿度
            subStandardSeries.doUse = this.standardSeriesForm.doUse; //是否应用
            subStandardSeries.mustZone = this.standardSeriesForm.mustZone //是否强制过0点
            if(subStandardSeries.doUse == null || subStandardSeries.doUse == ""
             || subStandardSeries.doUse == undefined){
              subStandardSeries.doUse =false
            }

            subStandardSeries.unitOne = this.isNotNull(this.unitTitle.unitOne, '标准物质浓度单位', clickOrTime);
            subStandardSeries.unitTwo = this.isNotNull(this.unitTitle.unitTwo, '标准物质用量单位', clickOrTime);
            subStandardSeries.unitThree = this.isNotNull(this.unitTitle.unitThree, '定容体积单位', clickOrTime);
            subStandardSeries.unitFour = this.isNotNull(this.unitTitle.unitFour, '配置浓度单位', clickOrTime);
            subStandardSeries.matterType = this.matterType; //单标或者混标
            subStandardSeries.configWay = this.configWay; //人工配置或者仪器配置
            for (var i in this.userData) { //循环人员列表，对比配置人校核人共同完成人 取账户和名字
                if (this.standardSeriesForm.configMan == this.userData[i].account) { // 检测人
                    subStandardSeries.configMan = this.userData[i].account;
                    subStandardSeries.configManName = this.userData[i].name;
                }
                if (this.standardSeriesForm.checker == this.userData[i].account) { // 校核人
                    subStandardSeries.checker = this.userData[i].account;
                    subStandardSeries.checkerName = this.userData[i].name;
                }

            }
            for (var i in this.standardSolution) {
                this.isNotNull(this.standardSolution[i].name, "标准溶液名称", clickOrTime);
            }
            subStandardSeries.solutionBeans = this.standardSolution; //标准溶液

            if(clickOrTime != 'time'){ //点击确定状态传1
                subStandardSeries.status = 1;
            }else{ //如果是定时保存的话  有状态则传状态，没有则传0
                subStandardSeries.status = this.standardSeriesForm.status == undefined ? 0 : this.standardSeriesForm.status; //状态
            }
            var temp = [];
            for (var i in this.standardSeries) { //标准系列数据处理
                var obj = {};
                obj.itemName = this.isNotNull(this.standardSeries[i].seriesItem, "标准系列项目名", clickOrTime);
                obj.unitOne = this.isNotNull(this.standardSeries[i].custom.standardSeriesChild[0].unitValue, '标准使用液浓度单位', clickOrTime);
                obj.unitTwo = this.isNotNull(this.standardSeries[i].custom.standardSeriesChild[1].unitValue, '标准物质用量单位', clickOrTime);
                obj.unitThree = this.isNotNull(this.standardSeries[i].custom.standardSeriesChild[2].unitValue, '定容量单位', clickOrTime);
                obj.unitFour = this.isNotNull(this.standardSeries[i].custom.standardSeriesChild[3].unitValue, '标准系列浓度单位', clickOrTime);
                obj.seriesBeans = []
                for (var j in this.standardSeries[i].custom.colsData) { //遍历添加了几列数据
                    var a = Number(j) + Number(1);
                    var std = 'std' + a
                    var series = {};
                    series.seriesSort = std;
                    series.criterionConcen = this.standardSeries[i].custom.standardSeriesChild[0][std]
                    series.matterAmount = this.standardSeries[i].custom.standardSeriesChild[1][std]
                    series.volum = this.standardSeries[i].custom.standardSeriesChild[2][std]
                    series.seriesConcen = this.standardSeries[i].custom.standardSeriesChild[3][std]

                    if (clickOrTime != 'time') { //点击保存时验证
                        //目的: 人工配制的都要填，仪器配制的其第二三行可以不填
                        if (series.criterionConcen == undefined || series.seriesConcen == undefined) { //第一个值或者第四个值为空
                            //若4个值都为空，则直接忽略
                            if (series.criterionConcen == undefined && series.matterAmount == undefined && series.volum == undefined && series.seriesConcen == undefined) {
                                continue;
                            } else {
                                //若第一个值或者第四个值为空，则提示不能通过
                                this.$message({
                                    type: 'info',
                                    message: '标准使用液浓度或者标准系列浓度不能为空！'
                                })
                                return;
                            }
                        } else { //第一个值和第四个值不为空
                            if (this.configWay == '1') { //人工配置
                                if (series.matterAmount == undefined || series.volum == undefined) { //若第二个值和第三个值为空
                                    this.$message({
                                        type: 'info',
                                        message: '人工配置下，标准物质用量或者定容量不能为空！'
                                    })
                                    return;
                                }
                            }
                            obj.seriesBeans.push(series);
                        }
                    }else{
                         obj.seriesBeans.push(series);
                    }

                }
                temp.push(obj)
            }
            subStandardSeries.itemBeans = temp;

            if (this.breakFlag == 0) {
                return;
            }
            if (this.newOrEdit == 'new') {
                console.log(this.criterionId)
                if (this.criterionId == '' || this.criterionId == null || this.criterionId == undefined) {
                    var url = '/detection/addCriterion.htm';
                } else {
                    var url = '/detection/updateCriterion.htm';
                    subStandardSeries.id = this.criterionId;
                }

            } else if (this.newOrEdit == 'edit') {
                var url = '/detection/updateCriterion.htm';
                subStandardSeries.id = this.criterionId;
            }

            if (clickOrTime == 'time') {
                subStandardSeries.submitType = 0
                this.isSuccess = false;
            } else {
                subStandardSeries.submitType = 1
                clearInterval(this.setIntervalTimes)
            }
            // return;
            this.$http({
                method: 'post',
                apiUrl: url,
                params: subStandardSeries,
                isJson: true,
            }).then(res => {
                if (res.code === 0) {
                    if (clickOrTime == 'time'){
                         this.isSuccess = true;
                    }
                    if (this.newOrEdit == 'new' && this.criterionId == '') { //如果是新增曲线 并且criterionId为空，把返回成功的id复制给criterionId，下一次定时保存就会调用updateCriterion接口
                        this.criterionId = res.data;
                    }

                    this.testpanelForm.hasCriterion = true; //如果是true  按钮为查看标准系列
                    // 把样品添加到已选样品列表
                    if (clickOrTime != 'time') { //如果是定时保存 不把样品加入列表和关闭弹框
                        var standardSample = [];
                        var arrLen = this.testpanelForm.sampleBeans.length;
                        for (var i = arrLen - 1; i >= 0; i--) { //先删除已选样品中的标准系列样品
                            if (this.testpanelForm.sampleBeans[i].doStandard != undefined && this.testpanelForm.sampleBeans[i].doStandard) {
                                this.testpanelForm.sampleBeans.splice(i, 1)
                            }
                        }
                        // 再判断是否勾选了‘是否应用’，如果勾选了再加入，不勾选 则不再加入
                        if (this.standardSeriesForm.doUse) {
                            this.readQcTypes(subStandardSeries.itemBeans[0].seriesBeans);
                        } else {
                            this.closeStandardSeriesShow();
                        }
                    }
                }
            })
        },
        // 提交标准系列 点击提交需要验证上面表单数据是否为空
        subStandard() {
            this.$refs.standardSeriesForm.validate((valid) => { //表单验证
                if (valid) {
                    this.clickOrTimeSub("click");
                } else {
                    return false;
                }
            });
        },
        // /qc/readQcTypes.htm
        readQcTypes(beans) {
            var standardSample = [];
            this.$http({
                method: 'post',
                apiUrl: '/qc/readQcTypes.htm',
                params: {
                    genre: "QCB04"
                },
                isJson: false
            }).then(res => {
                if (res.code == 0) {
                    for (var j in beans) {
                        var obj = {};
                        obj.sampleName = "标准系列" + beans[j].seriesSort;
                        obj.doStandard = true;
                        obj.qcType = res.data[0].code;
                        obj.qcTypeName = res.data[0].name;
                        obj.sampleCode = '/';
                        // obj.taskName = '---';
                        standardSample.unshift(obj)
                    }
                    var list = this.util.repeatData({
                        old: this.testpanelForm.sampleBeans,
                        new: standardSample,
                        unique: 'sampleName'
                    })
                    this.testpanelForm.sampleBeans = this.$parent.sampleSort(list);
                    console.log(this.testpanelForm.sampleBeans)
                    this.closeStandardSeriesShow();

                }
            })
        },
        // 赋值标准系列
        copyStandardSeries(row) {
            var colsData = JSON.parse(JSON.stringify(row.custom.colsData))
            var standardSeriesChild = JSON.parse(JSON.stringify(row.custom.standardSeriesChild))
            this.standardSeries.push({
                seriesItem: '',
                custom: {
                    standardSeriesChild,
                    colsData
                },

            })
        },
        // 查看历史曲线
        historyLine() {

        },
        // 点击取消和关闭按钮 判断是否提交
        closeStandardSeries(){
            console.log(this.standardSeriesForm.status,this.standardSeriesForm)
             if(this.standardSeriesForm.status == 0){
                this.$confirm('标准溶液信息未提交,确定离开吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.closeStandardSeriesShow();
                }).catch(() => {
                    this.$message({
                    type: 'info',
                    message: '已取消'
                    });
                });
            }else{
                this.closeStandardSeriesShow();
            }
        },
        closeStandardSeriesShow() {
            this.$refs.standardSeriesForm.resetFields();
            this.$emit('update:addVisible', false)
            this.name = '';
            this.unitTitle = {
                unitOne: '',
                unitTwo: '',
                unitThree: '',
                unitFour: '',
            };
            this.matterType = 1; //默认单标
            this.configWay = 1; // 配置方式默认为人工配置

            this.standardSeriesForm = {
                code: '',
                configDate: this.util.date(),
                temperature: '',
                humcodeity: '',
                doUse: false,
                configMan: JSON.parse(sessionStorage.getItem('laboratoryAccountInfo')).loginid,
                checker: '',
                mustZone:true,

            };
            this.criterionId = '';
            this.standardSolution = [];
            this.standardSeries = [];
            this.activeName = 'first';
            clearInterval(this.setIntervalTimes)
            this.isSuccess = true;
        },

        // getCoefficient(x1, y1, arr) {

        //     var that = this;
        //     var ySignal = null;
        //     var x = x1;
        //     var y = y1;
        //     if (x.length > 0) {
        //         for (var i in x) { //获取到浓度为0的信号值
        //             if (x[i] == 0) {
        //                 ySignal = y[i];
        //                 break;
        //             }
        //         }
        //         if (ySignal == null) {
        //             this.$notify({
        //                 title: "警告",
        //                 type: "warning",
        //                 message: "无法查到标准系列浓度为0 的标准系列空白样品,无法计算曲线",

        //             })
        //             return;
        //         } else { //所有的信号值减去ySignal
        //             for (var j in y) {
        //                 y[j] = Number(this.$math.eval(y[j] - ySignal)).toFixed(4);
        //             }
        //         }
        //     }
        //     if (x.length == 0 || y.length == 0) {
        //         return;
        //     }

        //     var data = [];
        //     this.$http({
        //         method: 'post',
        //         apiUrl: '/detection/getCoefficient.htm',
        //         params: {
        //             x: x1,
        //             y: y1
        //         },
        //         isJson: true
        //     }).then(res => {
        //         console.log(res.data)
        //         // 	getCoefficientObj:{
        //         // 	coefficent:null, //相关系数
        //         // 	deviation:null, //截距
        //         // 	deviation:null, //斜率
        //         // }
        //         this.getCoefficientObj.coefficent = res.data.coefficent.toFixed(4);
        //         this.getCoefficientObj.deviation = res.data.deviation.toFixed(4);
        //         this.getCoefficientObj.slope = res.data.slope.toFixed(4);
        //         //根据截距与斜率计算两个点位
        //         var newArr = this.getLinePoint(arr, ySignal);

        //         var fuhao = null
        //         if (Number(res.data.deviation) >= 0) {
        //             fuhao = '* x +' + res.data.deviation.toFixed(6); //截距
        //         } else {
        //             fuhao = '* x ' + res.data.deviation.toFixed(6)
        //         }
        //         var cron = "y = " + res.data.slope.toFixed(6) + fuhao

        //         setTimeout(function() {
        //             that.drawLine(newArr, cron);
        //         }, 300)
        //     })
        // },
        getCoefficient(x1, y1, arr) {

            var that = this;
            var x = x1;
            var y = y1;

            var y0 = 0
            if (x.length > 0) {

              if(this.standardSeriesForm.mustZone){
                y0 = y[0]
                for (var j in y) {
                    y[j] = Number(this.$math.eval(y[j] - y0)).toFixed(4);
                }
              }

            }
            if (x.length == 0 || y.length == 0) {
                return;
            }

            var data = [];
            this.$http({
                method: 'post',
                apiUrl: '/detection/getCoefficient.htm',
                params: {
                    x: x1,
                    y: y1
                },
                isJson: true
            }).then(res => {
                console.log(res.data)
                this.getCoefficientObj.coefficent = res.data.coefficent.toFixed(4);
                this.getCoefficientObj.deviation = res.data.deviation.toFixed(4);
                this.getCoefficientObj.slope = res.data.slope.toFixed(4);
                //根据截距与斜率计算两个点位
                var newArr = this.getLinePoint(arr, y0);

                var fuhao = null
                if (Number(res.data.deviation) >= 0) {
                    fuhao = '* x +' + res.data.deviation.toFixed(6); //截距
                } else {
                    fuhao = '* x ' + res.data.deviation.toFixed(6)
                }
                var cron = "y = " + res.data.slope.toFixed(6) + fuhao

                setTimeout(function() {
                    that.drawLine(newArr, cron);
                }, 300)
            })
        },
        getLinePoint(arr, ySignal) { //将 每个信号值 减去 浓度为0的信号值
            for (var i in arr) {
                arr[i][1] = arr[i][1] - ySignal;
                arr[i][1] = Number(this.$math.eval(arr[i][1])).toFixed(4)
            }
            return arr;
        },
        drawLine(arr, cron) { //arr是点位数据，cron是表达式
            //
            let seriesMap = this.$echarts.init(document.getElementById('seriesMap'))
            // 绘制图表
            var dataAll = arr; //所有点位

            // 取所有点中x轴最大数据和y轴最大数据,用来控制x轴和y轴长度
            var xMax = null;
            var yMax = null;
            for (var i in arr) {
                xMax = (xMax <Number(arr[i][0])) ? Number(arr[i][0]) : xMax;
                yMax = (yMax < Number(arr[i][1])) ? Number(arr[i][1]) : yMax;
            }

            var markLineOpt = {
                animation: false,
                label: {
                    normal: {
                        formatter: cron,
                        textStyle: {
                            align: 'right'
                        }
                    }
                },
                lineStyle: {
                    normal: {
                        type: 'solid',
                    }
                },
                tooltip: {
                    formatter: cron
                },
                data: [
                    [{
                        coord: arr[0],
                        symbol: 'none'
                    }, {
                        coord: arr[arr.length - 1],
                        symbol: 'none'
                    }]
                ]
            };
            seriesMap.setOption({
                title: {
                    text: '曲线图谱',
                    x: 'center',
                    y: 0,
                    textStyle: {
                        fontSize: 14
                    }
                },
                grid: [{
                    x: 'center',
                    y: 'center',
                    width: '80%',
                    height: '80%'
                },],
                tooltip: {
                    formatter: '{a} : ({c})'
                },
                xAxis: [{
                    gridIndex: 0,
                    min: 0,
                    max: xMax,
                    name: '浓度'
                },],
                yAxis: [{
                    gridIndex: 0,
                    min: 0,
                    max: yMax,
                    name: '信号值'
                },],
                series: [{
                    name: '坐标',
                    type: 'scatter',
                    xAxisIndex: 0,
                    yAxisIndex: 0,
                    data: dataAll,
                    markLine: markLineOpt,
                    itemStyle: {
                        color: '#409EFF'
                    }
                }]
            });
        },
        // 模拟file的点击事件
        uploadClick() {
            document.getElementById("file").click()
        },
        // 上传文件
        upload(event) {
            var files = document.getElementById('file').files;
            var formData = new FormData();
            for(var i of files){
                formData.append('file', i)
            }
            formData.append('ids', this.testpanelForm.id)
            formData.append('type', 3)
            formData.append('taskType', null)
            formData.append('detectability', null)
            formData.append('fileType', 'standardSeries')
            this.$axios({
                method: 'post',
                url: '/download/fileUpload.htm',
                data: formData,
                headers: {
                    'Content-Type': 'multipart/form-data',
                    'token':sessionStorage.getItem('loginAccount')?sessionStorage.getItem('loginAccount'):undefined
                }
            }).then(res => {
                 event.target.value= "";
                var data = res.data
                if (data.code == 0) {
                    this.$notify({
                        title: '消息',
                        message: '上传成功',
                        type: 'success'
                    })
                    this.getFilePath();
                } else {
                    this.$message({
                        type: 'info',
                        message: data.description,
                    })
                }

            })
        },
        // getFilePathByIds
        getFilePath() {
            this.$http({
                method: 'post',
                apiUrl: '/download/getFilePathByIds.htm',
                params: {
                    ids: this.testpanelForm.id
                },
                isJson: false,
            }).then(res => {
                if (res.code == 0) {
                    this.attachmentBeanList = res.data
                }
            })
        },
        //删除方法附件
        deleteattachment(row) {
            this.$confirm('是否删除', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$http({
                    method: 'post',
                    apiUrl: '/download/fileDelete.htm',
                    params: {
                        id: row.id,
                    },
                    isJson: false,
                }).then(res => {
                    if (res.code === 0) {
                        this.$message({
                            type: 'success',
                            message: '删除成功!'
                        });
                        this.getFilePath()
                    }
                })
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
        },
        // 下载附件
        downloadattachment(row) {
            var url = "/download/fileDownload.htm"
            let token = sessionStorage.getItem('loginAccount')?sessionStorage.getItem('loginAccount'):undefined
            window.open(process.env.baseUrl + url + '?id=' + row.id  + "&token=" + token);
        },

    }

}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style>
.addSampleForm .el-dialog {
    height: 85%;
    margin-top: 7vh !important;
}

.addSampleForm .el-dialog .el-form-item {
    margin-bottom: 20px;
}

.addSampleForm .el-dialog .el-dialog__body {
    height: calc(100% - 85px);
    padding: 10px;
}
.dataEntrySeries.addSampleForm .el-dialog .el-dialog__body {
    height: calc(100% - 45px);
}



/*标准系列标题样式*/

.standardTitle {
    height: 42px;
    line-height: 20px;
    text-align: center;
}

.standardTitle .el-input {
    width: 24%;
    margin-right: 8px;
}

.standardTitle .el-input .el-input__inner,
.borderBottom .el-input__inner {
    border: none;
    border-bottom: 1px solid #dcdfe6;
    border-radius: 0;
}
.standardseries.addSampleForm .el-dialog .el-dialog__body .form {
    height: 105px;
}

.standardseries.addSampleForm .el-dialog .el-dialog__body .form .el-form-item {
    width: 24%;
    display: inline-block;
    margin-bottom: 10px;
}

.standardseries .standardTable {
    /*height: calc((100% - 95px - 42px)/2);*/
    height: calc(100% - 105px - 42px);

    padding: 0 10px;
}

.standardTable .el-tabs.el-tabs--top {
    height: 100%;
}

.standardTable .el-tabs__content {
    height: calc(100% - 55px)
}

.standardTable .el-tabs__content .el-tab-pane {
    height: 100%
}

.standardseries .standardTable .el-table {
    height: calc(100% - 30px)
}

.standardseries .checkbox {
    height: 30px;
    padding: 0 20px;
    line-height: 36px;
}

.standardTable .solution .el-table__fixed-body-wrapper,
.standardTable .solution .el-table__body-wrapper {
    height: calc(100% - 82px);
    overflow: auto;
}

.standardTable .seriesTable>.el-table__body-wrapper>.el-table__body>tbody>tr>td:nth-of-type(3),
.standardTable .seriesTable>.el-table__body-wrapper>.el-table__body>tbody>tr>td:nth-of-type(3)>.cell {
    padding: 0;
}

.seriesChildTable .el-table__header-wrapper .has-gutter th,
.seriesChildTable .el-table__fixed .el-table__fixed-header-wrapper th {
    background: none !important;
}

.seriesChildTable tr td:nth-of-type(1),
.seriesChildTable tr th:nth-of-type(1) {
    border-right: none;
}

.seriesChildTable tr th:nth-of-type(1) .cell,
.seriesChildTable tr td:nth-of-type(1) .cell {
    text-align: right;
}

.unitSolution {
    padding-right: 0px !important;
    padding-left: 0px !important;
}

.unitSolution .el-input__suffix {
    right: 10px;
}

.unitSeries .el-input__suffix {
    right: 0px;
}

.unitSeries .el-input__inner,
.unitSolution .el-input__inner {
    padding-right: 22px;
    padding-left: 10px;
}

.seriesChildTable tr th:nth-of-type(1) .cell,
.seriesChildTable tr td:nth-of-type(1) .cell {
    text-align: right;
    padding: 0;
}

.seriesChildTable .controlsPosition {
    width: 100%;
}

.controlsPosition .el-input__inner {
    text-align: left;
}

.seriesChildTable .controlsPosition .el-input__inner {
    padding-left: 5px;
    padding-right: 5px;
    text-align: center;
}

.solution .el-table__fixed-body-wrapper {
    top: 83px !important;
}
</style>
